<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

    <base href="<%=basePath%>">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css" />
	<link rel="stylesheet" type="text/css" href="easyui/themes/icon.css" />
	<link rel="stylesheet" type="text/css" href="css/index.css" />
	<title>index Page</title>

</head>

<body class="easyui-layout">
    
	<div data-options="region:'north',title:'header',split:true,noheader:true" style="height:70px;background:#666;">
		<div class="logo">酒店后台管理系统</div>
		<div class="logout">
			您好，<s:property value="#session.user.userName"/> | <a href="loginAction!logout">退出</a>
		</div>
	</div>   

	<div data-options="region:'west',title:'导航',split:true,iconCls:'icon-world'" style="width:180px;padding:10px;">
		<div id="nav"></div>
	</div>   

	<div data-options="region:'center'" style="overflow:hidden;">
		<div id="tabs">
			<div title="起始页"  iconCls="icon-house"  style="padding:0 10px;display:block;">
				<iframe scrolling="auto" frameborder="0"  src="<%=path%>/orderAction" style="width:100%;height:100%;"></iframe>
			</div>
		</div>
	</div>
	   
	<div id=mm class="easyui-menu" style="width:150px;">
		<div id="mm-tabclose">关闭</div>
		<div id="mm-tabcloseall">全部关闭</div>
		<div id="mm-tabcloseother">除此之外全部关闭</div>
		<div class="menu-sep"></div>
		<div id="mm-tabcloseright">当前页右侧全部关闭</div>
		<div id="mm-tabcloseleft">当前页左侧全部关闭</div>
		<div class="menu-sep"></div>
		<div id="mm-exit">退出</div>
	</div> 
	
	<script type="text/javascript" src="easyui/jquery.min.js"></script>
	<script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="easyui/locale/easyui-lang-zh_CN.js" ></script>
	<script type="text/javascript" >
		$(function () { 	
			$('#nav').tree({
				url: "treeAction!syncMenu?date="+new Date()+"",
			    lines: true,
			    onClick: function(node) {
			    	var isLeaf = node.isLeaf;
			    	if (isLeaf == 1){
			    		var menu_name = node.menu_name;
			    		var menu_href = node.menu_href;
					    if (!$('#tabs').tabs('exists', menu_name)) {
					        $('#tabs').tabs('add', {
					            title: menu_name,
					           // href : menu_href,
					            content : '<iframe scrolling="auto" frameborder="0"  src="' + menu_href + '" style="width:100%;height:100%;"></iframe>',
					            closable: true,
					            icon: node.iconCls
					        });
					    } else {
					        $('#tabs').tabs('select', menu_name);
					    }
					    tabClose();	    	
			    	}
			    },
			});
			
			$('#tabs').tabs({
				fit : true,
				border : false
			});
			
			function tabClose() {
			    /*双击关闭TAB选项卡*/
			    $(".tabs-inner").dblclick(function() {
			        var subtitle = $(this).children(".tabs-closable").text();
			        $('#tabs').tabs('close', subtitle);
			    });
			    /*为选项卡绑定右键*/
			    $(".tabs-inner").bind('contextmenu',
			    function(e) {
			        $('#mm').menu('show', {
			            left: e.pageX,
			            top: e.pageY
			        });
			
			        var subtitle = $(this).children(".tabs-closable").text();
			
			        $('#mm').data("currtab", subtitle);
			        $('#tabs').tabs('select', subtitle);
			        return false;
			    });
			}
			//绑定右键菜单事件
			
			//关闭当前
			$('#mm-tabclose').click(function() {
			    var currtab_title = $('#mm').data("currtab");
			    $('#tabs').tabs('close', currtab_title);
			});
			//全部关闭
			$('#mm-tabcloseall').click(function() {
			    $('.tabs-inner span').each(function(i, n) {
			        var t = $(n).text();
			        if (t != "首页") {
			            $('#tabs').tabs('close', t);
			        }
			
			    });
			});
			//关闭除当前之外的TAB
			$('#mm-tabcloseother').click(function() {
			    var currtab_title = $('#mm').data("currtab");
			    $('.tabs-inner span').each(function(i, n) {
			        var t = $(n).text();
			        if (t != "首页") {
			            if (t != currtab_title) $('#tabs').tabs('close', t);
			        }
			    });
			});
			//关闭当前右侧的TAB
			$('#mm-tabcloseright').click(function() {
			    var nextall = $('.tabs-selected').nextAll();
			    if (nextall.length == 0) {
			        //msgShow('系统提示','后边没有啦~~','error');
			        alert('后边没有啦~~');
			        return false;
			    }
			    nextall.each(function(i, n) {
			        var t = $('a:eq(0) span', $(n)).text();
			        if (t != "首页") {
			            $('#tabs').tabs('close', t);
			        }
			    });
			    return false;
			});
			//关闭当前左侧的TAB
			$('#mm-tabcloseleft').click(function() {
			    var prevall = $('.tabs-selected').prevAll();
			    if (prevall.length == 0) {
			        alert('到头了，前边没有啦~~');
			        return false;
			    }
			    prevall.each(function(i, n) {
			        var t = $('a:eq(0) span', $(n)).text();
			
			        if (t != "首页") {
			            $('#tabs').tabs('close', t);
			        }
			    });
			    return false;
			});
			
			//退出
			$("#mm-exit").click(function() {
			    $('#mm').menu('hide');
			});
			
		});
	</script>

</body>
</html>